import { ICell } from "./ICell";

export class Cell implements ICell {
    constructor(x: number, y: number) {
        this.x = x;
        this.y = y;
        this.key = this.x + ',' + this.y;
    }
    public x: number;
    public y: number;
    public key: string;

    public getAroundPosition(): { x: number; y: number, key: string }[] {
        let positions: any[] = [];
        const positionArray = [-1, 0, 1];
        positionArray.forEach(xp =>
            positionArray.forEach(yp => {
                if (!(xp == 0 && yp == 0)) {
                    const x = this.x + xp;
                    const y = this.y + yp;
                    positions.push({ x, y, key: x + ',' + y })
                }
            })
        )
        return positions;
    }
}